package com.example.java.Controller;

import com.example.java.Entity.Admin;
import com.example.java.Service.AdminService;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/admin")
public class AdminController {

    private List<Admin> admins = new ArrayList<>();

    @Resource
    private AdminService adminService;

    //    查询所有
    @GetMapping("/all")
    public List<Admin> alladmin(){
        return adminService.alladmin();
    }

    //    增加或修改
    @PostMapping("/pos")
    public Integer addandedit(@RequestBody Admin admin) {
        return adminService.addandedit(admin);
    }

    //    删除
    @DeleteMapping("/delete/{id}")
    public Integer delete(@PathVariable Integer id){
        return adminService.deleteById(id);
    }

    //    模糊查询
    @GetMapping("/getLike/{keyword}")
    public List<Admin> getLike(@PathVariable String keyword) {
        return adminService.getLike(keyword);
    }

}
